package com.wlz.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wlz.demo.controller.vo.BarVO;
import com.wlz.demo.controller.vo.DataVO;
import com.wlz.demo.entity.Hobby;
import com.wlz.demo.mapper.HobbyMapper;
import com.wlz.demo.service.IHobbyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class IHobbyServiceImpl extends ServiceImpl<HobbyMapper, Hobby>  implements IHobbyService {


    @Autowired
    private HobbyMapper hobbyMapper;

    @Override
    public BarVO barvo() {
        BarVO barVO = new BarVO();
        List<String> names = new ArrayList<>();
        List<DataVO> values = new ArrayList<>();

        List<Hobby> hobbies = hobbyMapper.selectList(null);
        for (Hobby hobby : hobbies) {
            names.add(hobby.getHobbyName());
            DataVO dataVO = new DataVO();
            dataVO.setValueStar(hobby.getHobbyStar());
            dataVO.setValueSpendTime(hobby.getHobbySpendTime());
//            Map<String,String> map = new HashMap<>();
//            map.put("valueStar",hobby.getHobbyStar());
//            map.put("valueSpendTime",hobby.getHobbySpendTime());
//            dataVO.setItemStyle(DataColorUitl.createItemStyle(hobby.getHobbyStar()));
            values.add(dataVO);
        }
        barVO.setNames(names);
        barVO.setValues(values);
        return barVO;
    }
}
